package com.bootdo.app.config;

import lombok.Data;

/**
 * @auther: Along
 * @description: 微信配置类
 */
@Data
//@Component
//@ConfigurationProperties(value = "wechat.mini-program")
public class WXConfig {

    // 商户号
    private static final String WX_PAY_MCH_ID = "1554095611";
    public static String getWxPayMchId(){
        return WX_PAY_MCH_ID;
    }
    // 商户账号appid
    private static final String WX_PAY_MCH_APP_ID = "wx27561fe9322705ce";
    public static String getWxPayMchAppId(){
        return WX_PAY_MCH_APP_ID;
    }

    // 商户平台设置的支付密钥key
    private static final String WX_PAY_KEY = "ad3f8d24e7ede142fa3174e750c2b670";
    public static String getWxPayKey(){
        return WX_PAY_KEY;
    }

    // 设置证书路径C:\Users\10148\Desktop\ssl
    private static final String SSL_FILE_PATH = WXConfig.class.getClassLoader().getResource("wxSSLConfig/apiclient_cert.p12").getPath();
    public static String getSslFilePath(){
        return SSL_FILE_PATH;
    }

    private static String CODE2SESSION_URL = "https://api.weixin.qq.com/sns/jscode2session";
    private static String TRANSFER_MONEY_TO_USER_URL = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";
    public static String getTransferMoneyToUserUrl(){
        return TRANSFER_MONEY_TO_USER_URL;
    }

    // 微信AccessToken
    private static final String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
    public static String getAccessTokenUrl(String appId,String appSecret){
        return ACCESS_TOKEN_URL.replace("APPID",appId).replace("APPSECRET",appSecret);
    }

    // 创建微信公众号菜单
    private static final String CREATE_WX_MENU_URL = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN";
    public static String getCreateWxMenuUrl(String wxAccessToken){
        return CREATE_WX_MENU_URL.replace("ACCESS_TOKEN",wxAccessToken);
    }

    // 发送微信公众号模板消息
    private static final String SEND_TEMPLATE_MSG_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN";
    public static String getSendTemplateMsgUrl(String wxAccessToken){
        return SEND_TEMPLATE_MSG_URL.replace("ACCESS_TOKEN",wxAccessToken);
    }

    public static String initCode2Session(String appId,String appSecret,String code) {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(CODE2SESSION_URL);
        return stringBuffer.append("?js_code=").append(code)
                .append("&grant_type=authorization_code")
                .append("&appid=").append(appId)
                .append("&secret=").append(appSecret)
                .toString();
    }




}
